<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class ChoiceRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title' => 'required',
            'option_a' => 'sometimes|required',
            'option_b' => 'sometimes|required',
            'option_c' => 'sometimes|required',
            'option_d' => 'sometimes|required',
            'answer' => 'required'
        ];
    }

    public function messages()
    {
        return [
            'title.required' => '题目必须填写！',
            'option_a.required' => '选项A必须填写！',
            'option_b.required' => '选项B必须填写！',
            'option_c.required' => '选项C必须填写！',
            'option_d.required' => '选项D必须填写！',
            'answer.required' => '请填选正确答案！'
        ];
    }
}
